Release 10.1A: OpenEdge Getting Started:
Object-oriented Programming
Method scoping within the class hierarchy
A class can access all of the
PUBLICandPROTECTEDmethods of its super class as well as any methods that it defines. A super class that, in turn, inherits from another class inherits all its super class'sPUBLICandPROTECTEDmethods and so on to the root of the hierarchy. Therefore when a class inherits all of thePUBLICandPROTECTEDmethods of its super class, it inherits all of thePUBLICandPROTECTEDmethods available to the top of the class hierarchy.While a subclass can access the
PUBLICandPROTECTEDmethods of its super class the reverse is not true. A super class cannot invoke any method in any of its subclasses unless the method is defined in the super class and overridden in the subclass. Methods defined only in a subclass are simply not visible to its super classes. Likewise, methods defined asPRIVATEin a super class are not visible to its subclasses. Since the access mode for a method must be specified as part of the method definition, a method must be explicitly defined as eitherPROTECTEDorPUBLICto be accessible to other classes in the hierarchy. A key benefit of the new syntax for classes is thePROTECTEDaccess mode, which lets you define an interrelated set of method definitions accessible within a class hierarchy, but invisible to other classes or procedures.Comparison with procedure-based programming
By comparison, internal procedures and functions are always public by default, which means that they can be executed from within a super procedure stack (through the
RUNSUPERstatement orSUPERbuilt-in function), or from unrelated procedures. You can define internal procedures and functions asPRIVATEto restrict access to the defining procedure alone.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |